package thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorThread {

    public static void main(String[] args) {
        ExecutorService executorService= Executors.newCachedThreadPool();
        LiftOff liftOff = new LiftOff(10);
        executorService.execute(liftOff);
        executorService.execute(liftOff);
    }

}

class LiftOff implements Runnable{

    protected  int countDown=10;

    private static int taskcount =0;

    private final int id= taskcount++;



    public LiftOff() {
    }

    public LiftOff(int countDown) {
        this.countDown = countDown;
    }

    public String status(){
        return Thread.currentThread().getName()+"#"+id+"("+(countDown>0?countDown:"Liftoff!")+")";
    }

    @Override
    public void run() {
        while (countDown-- >0){
            System.out.println(status());
            Thread.yield();
        }
    }
}